package manage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import manage.dao.PeopleChangeMapper;
import manage.model.PeopleChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PeopleChangeServiceImpl {
    @Autowired
    private PeopleChangeMapper peopleChangeMapper;
    public PageInfo<PeopleChange> selectAll(String page, String limit) {

        int pu = Integer.parseInt(page);
        int li = Integer.parseInt(limit);

        PageHelper.startPage(pu,li);
        List<PeopleChange> list = peopleChangeMapper.selectAll();
        PageInfo<PeopleChange> pageInfo = new PageInfo<PeopleChange>(list);
        return pageInfo;
    }

    public String insert(PeopleChange record) {

        int i = peopleChangeMapper.insert(record);
        if(i>0)
            return "success";
        return "fail";
    }

    public String del(Integer id) {
        int i = peopleChangeMapper.deleteByPrimaryKey(id);
        if(i>0)
            return "success";
        return "fail";
    }

    public PeopleChange select(Integer id) {
        return peopleChangeMapper.selectByPrimaryKey(id);
    }

    public String update(PeopleChange record){
        if(peopleChangeMapper.updateByPrimaryKey(record)>0)
            return "success";
        return "fail";
    }

}
